<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2018/8/30
 * Time: 下午1:04
 */
function error($message = '错误', $code = 500)
{
    return ['code' => $code, 'message' => $message];
}

function success(array $message = [], $code = 200)
{
    $message['code'] = $code;
    return $message;
}


/**
 * 隐藏手机号
 * @param $cardNum
 * @return string
 */
function hidePhoneNum($cardNum)
{
    $suf = '****';
    $cardNum_asterisk = substr($cardNum, 0, 3) . $suf . substr($cardNum, -4, 4);
    return $cardNum_asterisk;
}


/**
 * 校验手机号格式
 * @param $mobile
 * @return bool
 */
function mobile($mobile)
{
    return !!preg_match("/^1[34578]{1}\d{9}$/", $mobile);
}